package com.dameng.dmga.metadata.service.impl;

import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.dameng.dmga.metadata.mapper.UserMapper;
import com.dameng.dmga.metadata.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * UserServiceImpl
 *
 * @author yilang
 * @date 2021/9/9 0009
 **/
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private UserMapper userMapper;

    public List selectAll(String dbName) {
        DynamicDataSourceContextHolder.push(dbName);//手动切换
        return  jdbcTemplate.queryForList("select * from user");
    }
    public List selectAll1(String dbName) {
        DynamicDataSourceContextHolder.push(dbName);//手动切换
        return  userMapper.selectUsers();
    }
}
